import javax.swing.*;
import javax.swing.filechooser.*;
import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @modulename Main
 * @description The Main handles the GUI interface for the program, and handles 
 * the flow of the program
 * @callsequence 
 * @errorstested 
 * @errorsgenerated 
 * @author Nick Lister
 * @createdate 10/14/09
 * @modlog <p>
 *         <ul>
 *         Who/When/Why
 *         <li>Travis - 10/26/09 - Updated to use new PassOne Class
 *         <li>Travis - 10/26/09 - Updated to use Debug Logger
 *         </ul>
 *         Coding Standards Met: "Signed Code Leader(Jaron)"
 *         <p>
 *         Testing Standards Met: "Signed Test Leader(Jamie)"
 */

public class Main extends javax.swing.JFrame {
	private static final long serialVersionUID = 1L;
	private File sourceText;
    private File intermediateFile;
    private File objectFile;
    private File assemblyListing;
	private JFileChooser fcOpen;
	private JFileChooser fcSave;
	private FileNameExtensionFilter txtFilter;
	private Boolean debugOutputIsOn;
	protected static final String systemPathSeparator = System.getProperty("file.separator");
	protected static final String newline = System.getProperty("line.separator");

	private javax.swing.JButton assembleButton;
    private javax.swing.JLabel assembleLabel;
    private javax.swing.JSeparator bottomSeparator;
    private javax.swing.JToggleButton debugButton;
    private javax.swing.JScrollPane logPane;
    protected static javax.swing.JTextArea logText;
    private javax.swing.JButton quitButton;
    private javax.swing.JButton resetButton;
    private javax.swing.JButton saveAssemblyListingButton;
    private javax.swing.JLabel saveAssemblyListingLabel;
    private javax.swing.JButton saveIntermediateFileButton;
    private javax.swing.JLabel saveIntermediateFileLabel;
    private javax.swing.JButton saveObjectFileButton;
    private javax.swing.JLabel saveObjectFileLabel;
    private javax.swing.JButton selectSourceCodeButton;
    private javax.swing.JLabel selectSourceCodeLabel;
    private javax.swing.JLabel titleLabel;
    private javax.swing.JSeparator topSeparator;


	public Main() {
		initComponents();
        txtFilter = new FileNameExtensionFilter("Text File", "txt");
        this.sourceText = new File("");
        this.intermediateFile = new File("");
        this.objectFile = new File("");
        this.assemblyListing = new File("");
        this.fcOpen = new JFileChooser();
        this.fcSave = new JFileChooser();
        this.getRootPane().setDefaultButton(this.selectSourceCodeButton);
        this.selectSourceCodeButton.requestFocusInWindow();
        this.debugOutputIsOn = false;
        this.logPane.setVisible(false);
        this.setSize(this.getWidth(),  (this.getHeight() - Main.logText.getHeight() - 15));
        this.logPane.setVisible(true);
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	private void initComponents() {

        selectSourceCodeButton = new javax.swing.JButton();
        saveIntermediateFileButton = new javax.swing.JButton();
        saveObjectFileButton = new javax.swing.JButton();
        saveAssemblyListingButton = new javax.swing.JButton();
        assembleButton = new javax.swing.JButton();
        debugButton = new javax.swing.JToggleButton();
        resetButton = new javax.swing.JButton();
        quitButton = new javax.swing.JButton();
        titleLabel = new javax.swing.JLabel();
        selectSourceCodeLabel = new javax.swing.JLabel();
        saveIntermediateFileLabel = new javax.swing.JLabel();
        saveObjectFileLabel = new javax.swing.JLabel();
        saveAssemblyListingLabel = new javax.swing.JLabel();
        assembleLabel = new javax.swing.JLabel();
        topSeparator = new javax.swing.JSeparator();
        bottomSeparator = new javax.swing.JSeparator();
        logPane = new javax.swing.JScrollPane();
        logText = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Assmble Your Code");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setLocationByPlatform(true);
        setName("mainFrame"); // NOI18N

        selectSourceCodeButton.setText("Select Source Code...");
        selectSourceCodeButton.setToolTipText("Click Here to Select Your Source Code");
        selectSourceCodeButton.setFocusPainted(false);
        selectSourceCodeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectSourceCodeButtonActionPerformed(evt);
            }
        });

        saveIntermediateFileButton.setText("Save Intermediate File...");
        saveIntermediateFileButton.setToolTipText("Click Here to Select Where to Output The Intermediate File");
        saveIntermediateFileButton.setEnabled(false);
        saveIntermediateFileButton.setFocusPainted(false);
        saveIntermediateFileButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveIntermediateFileButtonActionPerformed(evt);
            }
        });

        saveObjectFileButton.setText("Save Object File...");
        saveObjectFileButton.setToolTipText("Click Here to Select Where to Output The Object File");
        saveObjectFileButton.setEnabled(false);
        saveObjectFileButton.setFocusPainted(false);
        saveObjectFileButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveObjectFileButtonActionPerformed(evt);
            }
        });

        saveAssemblyListingButton.setText("Save Assembly Listing...");
        saveAssemblyListingButton.setToolTipText("Click Here to Select Where to Output The Assembly Listing File");
        saveAssemblyListingButton.setEnabled(false);
        saveAssemblyListingButton.setFocusPainted(false);
        saveAssemblyListingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAssemblyListingButtonActionPerformed(evt);
            }
        });

        assembleButton.setText("Assemble");
        assembleButton.setToolTipText("Click Here When You are Ready to Assemble Your Code!");
        assembleButton.setEnabled(false);
        assembleButton.setFocusPainted(false);
        assembleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                assembleButtonActionPerformed(evt);
            }
        });

        debugButton.setText("Debug");
        debugButton.setToolTipText("Click Here to Toggle Debug Pane");
        debugButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                debugButtonActionPerformed(evt);
            }
        });

        resetButton.setText("Reset");
        resetButton.setToolTipText("Clicking this Button will Immediately Reset the Program");
        resetButton.setDefaultCapable(false);
        resetButton.setFocusPainted(false);
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });

        quitButton.setText("Quit");
        quitButton.setToolTipText("Clicking this Button will Immediately Exit the Program");
        quitButton.setDefaultCapable(false);
        quitButton.setFocusPainted(false);
        quitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitButtonActionPerformed(evt);
            }
        });

        titleLabel.setFont(new java.awt.Font("Tahoma", 1, 18));
        titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        titleLabel.setText("     CSE 560 - Group 01 - Assembler");
        titleLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        selectSourceCodeLabel.setText("Select your Source Code.");

        saveIntermediateFileLabel.setText("Select a place to Save the Intermediate File.");
        saveIntermediateFileLabel.setEnabled(false);
        saveIntermediateFileLabel.setMaximumSize(new java.awt.Dimension(118, 14));
        saveIntermediateFileLabel.setMinimumSize(new java.awt.Dimension(118, 14));
        saveIntermediateFileLabel.setPreferredSize(new java.awt.Dimension(118, 14));

        saveObjectFileLabel.setText("Select a place to Save the Object File.");
        saveObjectFileLabel.setEnabled(false);
        saveObjectFileLabel.setMaximumSize(new java.awt.Dimension(118, 14));
        saveObjectFileLabel.setMinimumSize(new java.awt.Dimension(118, 14));
        saveObjectFileLabel.setPreferredSize(new java.awt.Dimension(118, 14));

        saveAssemblyListingLabel.setText("Select a place to Save the Assembly Listing.");
        saveAssemblyListingLabel.setEnabled(false);
        saveAssemblyListingLabel.setMaximumSize(new java.awt.Dimension(118, 14));
        saveAssemblyListingLabel.setMinimumSize(new java.awt.Dimension(118, 14));
        saveAssemblyListingLabel.setPreferredSize(new java.awt.Dimension(118, 14));

        assembleLabel.setText("Great! Click Assemble to Assemble you Code.");
        assembleLabel.setEnabled(false);

        logText.setColumns(20);
        logText.setEditable(false);
        logText.setLineWrap(true);
        logText.setRows(5);
        logText.setText("Output Log\n");
        logText.setToolTipText("This Text Box adds Output Messages when Assembling Code");
        logText.setWrapStyleWord(true);
        logText.setFocusable(false);
        logText.setMaximumSize(new java.awt.Dimension(2147483647, 100));
        logText.setRequestFocusEnabled(false);
        logText.setVerifyInputWhenFocusTarget(false);
        logPane.setViewportView(logText);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(161, 161, 161)
                .addComponent(resetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(quitButton)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(selectSourceCodeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(saveIntermediateFileButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(saveObjectFileButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(saveAssemblyListingButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(assembleButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(saveIntermediateFileLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                    .addComponent(saveObjectFileLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                    .addComponent(selectSourceCodeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                    .addComponent(saveAssemblyListingLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                    .addComponent(assembleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addComponent(topSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
            .addComponent(bottomSeparator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(logPane, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                    .addComponent(debugButton))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(titleLabel)
                    .addComponent(resetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(quitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(topSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(selectSourceCodeButton)
                    .addComponent(selectSourceCodeLabel))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveIntermediateFileButton)
                    .addComponent(saveIntermediateFileLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveObjectFileButton)
                    .addComponent(saveObjectFileLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveAssemblyListingButton)
                    .addComponent(saveAssemblyListingLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(assembleButton)
                    .addComponent(assembleLabel))
                .addGap(18, 18, 18)
                .addComponent(bottomSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(debugButton)
                .addGap(18, 18, 18)
                .addComponent(logPane, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>


	private void assembleButtonActionPerformed(java.awt.event.ActionEvent evt) {
		assembleButton.setEnabled(false);
		Main.appendDebugText("System Path Separator is " + Main.systemPathSeparator);
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		IntermediateFile.startIntermediateFile();
		SymbolTable.startSymbolTable();
		AssemblyListing.startAssemblyListing();
		SourceCode.startSourceCode(this.sourceText);
		ErrorHandler.startErrorHandler();
		ObjectFile.resetObjectFile();
		MOTtable.startMOTtable();
		POTtable.startPOTtable();
		
		String intermediateFileString;
		intermediateFileString = PassOne.run();
		try {
			FileHandler.writeFile(this.intermediateFile, intermediateFileString);
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		
		String assemblyListingString;
		PassTwo.run();
		assemblyListingString = FileFormatter.formatAssemblyListing();
		try {
			FileHandler.writeFile(this.assemblyListing, assemblyListingString);
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		
		String objectFileString;
		objectFileString = FileFormatter.formatObjectFile();
		try {
			FileHandler.writeFile(this.objectFile, objectFileString);
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		
		this.assembleLabel.setText("ASSEMBLY COMPLETE");
        this.assembleButton.setEnabled(false);
        logText.append("\nCOMPLETE");
        setCursor(null); //turn off the wait cursor
		setCursor(Cursor.getDefaultCursor());
		pack();
	}

	private void selectSourceCodeButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                       
        fcOpen.addChoosableFileFilter(this.txtFilter);
        if (this.fcOpen.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            this.sourceText = this.fcOpen.getSelectedFile();
            this.selectSourceCodeLabel.setText(this.sourceText.getAbsolutePath());
            this.saveIntermediateFileLabel.setEnabled(true);
            this.saveIntermediateFileButton.setEnabled(true);
            this.saveIntermediateFileButton.requestFocusInWindow();
        }
    }

	private void saveIntermediateFileButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                           
        fcSave.addChoosableFileFilter(this.txtFilter);
        this.intermediateFile = new File("IntermediateFile.txt");
        fcSave.setSelectedFile(this.intermediateFile);
        if (fcSave.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            this.intermediateFile = this.fcSave.getSelectedFile();
            this.saveIntermediateFileLabel.setText(this.intermediateFile.getAbsolutePath());
            this.saveObjectFileButton.setEnabled(true);
            this.saveObjectFileLabel.setEnabled(true);
            this.saveObjectFileButton.requestFocusInWindow();
        }
        
        try {
			FileHandler.createFile(this.intermediateFile, "");
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		} catch (IOException e) {
			assembleLabel.setText("IO ERROR, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
    } 

	private void quitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        System.exit(0);
    }

	private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        Main.logText.setText(null);
        Main.logText.append("Output Log\n");
        try {
			FileHandler.resetFile(this.assemblyListing);
			FileHandler.resetFile(this.intermediateFile);
			FileHandler.resetFile(this.objectFile);
		} catch (IOException e) {
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
        this.assembleLabel.setText("Great! Click Assemble to Assemble you Code.");
        this.assembleButton.setEnabled(true);
    }

	private void debugButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        if (!this.debugOutputIsOn) {
            //TURN DEBUG ON
            this.logPane.setVisible(true);
            this.debugOutputIsOn = true;
            this.setSize(this.getWidth(), (this.getHeight() + Main.logText.getHeight() + 15));
            pack();
        } else {
            //TURN DEBUG OFF
            this.debugOutputIsOn = false;
            this.logPane.setVisible(false);
            this.setSize(this.getWidth(),  (this.getHeight() - Main.logText.getHeight() - 15));
            pack();
        }
    }
	
	private void saveObjectFileButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                     
        fcSave.addChoosableFileFilter(this.txtFilter);
        this.objectFile = new File("ObjectFile.txt");
        fcSave.setSelectedFile(this.objectFile);
        if (fcSave.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            this.objectFile = this.fcSave.getSelectedFile();
            this.saveObjectFileLabel.setText(this.objectFile.getAbsolutePath());
            this.saveAssemblyListingButton.setEnabled(true);
            this.saveAssemblyListingLabel.setEnabled(true);
            this.saveAssemblyListingButton.requestFocusInWindow();
        }
        
        try {
			FileHandler.createFile(this.objectFile, "");
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		} catch (IOException e) {
			assembleLabel.setText("IO ERROR, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
    }
	
	private void saveAssemblyListingButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                          
        fcSave.addChoosableFileFilter(this.txtFilter);
        this.assemblyListing = new File("AssemblyListing.txt");
        fcSave.setSelectedFile(this.assemblyListing);
        if (fcSave.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            this.assemblyListing = this.fcSave.getSelectedFile();
            this.saveAssemblyListingLabel.setText(this.assemblyListing.getAbsolutePath());
            this.assembleButton.setEnabled(true);
            this.assembleLabel.setEnabled(true);
            this.assembleButton.requestFocusInWindow();
        }
        
        try {
			FileHandler.createFile(this.assemblyListing, "");
		} catch (FileNotFoundException e) {
			assembleLabel.setText("OUTPUT FILE NOT FOUND, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		} catch (IOException e) {
			assembleLabel.setText("IO ERROR, CHECK DEBUG");
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
    }

	public static void appendDebugText(String appendedText) {
		Main.logText.append(appendedText + "\n");
	}

	public static void main(String args[]) {
		try {
			// Set System L&F
			UIManager.setLookAndFeel(
					UIManager.getSystemLookAndFeelClassName());
		} 
		catch (UnsupportedLookAndFeelException e) {
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		catch (ClassNotFoundException e) {
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		catch (InstantiationException e) {
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		catch (IllegalAccessException e) {
			Main.appendDebugText("Error: " + e);
			e.printStackTrace();
		}
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Main().setVisible(true);
			}
		});
	}

}